//文物相关
package com.ruoyi.web.controller.system;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.AppArtifact;
import com.ruoyi.system.service.IAppArtifactService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 文物信息Controller
 * 
 * @author ruoyi
 * @date 2024-10-29
 */
@RestController
@RequestMapping("/app/system/artifact")
public class AppApiArtifactController extends BaseController
{
    @Autowired
    private IAppArtifactService appArtifactService;

    /**
     * 查询文物信息列表
     */
    @GetMapping("/list")
    public TableDataInfo list(AppArtifact appArtifact)
    {
        startPage();
        List<AppArtifact> list = appArtifactService.selectAppArtifactList(appArtifact);
        return getDataTable(list);
    }

    /**
     * 导出文物信息列表
     */
    @PostMapping("/export")
    public void export(HttpServletResponse response, AppArtifact appArtifact)
    {
        List<AppArtifact> list = appArtifactService.selectAppArtifactList(appArtifact);
        ExcelUtil<AppArtifact> util = new ExcelUtil<AppArtifact>(AppArtifact.class);
        util.exportExcel(response, list, "文物信息数据");
    }

    /**
     * 获取文物信息详细信息
     */
    @GetMapping(value = "/{artifactId}")
    public AjaxResult getInfo(@PathVariable("artifactId") Long artifactId)
    {
        return success(appArtifactService.selectAppArtifactByArtifactId(artifactId));
    }

    /**
     * 新增文物信息
     */
    @PostMapping
    public AjaxResult add(@RequestBody AppArtifact appArtifact)
    {
        return toAjax(appArtifactService.insertAppArtifact(appArtifact));
    }

    /**
     * 修改文物信息
     */
    @PutMapping
    public AjaxResult edit(@RequestBody AppArtifact appArtifact)
    {
        return toAjax(appArtifactService.updateAppArtifact(appArtifact));
    }

    /**
     * 删除文物信息
     */
	@DeleteMapping("/{artifactIds}")
    public AjaxResult remove(@PathVariable Long[] artifactIds)
    {
        return toAjax(appArtifactService.deleteAppArtifactByArtifactIds(artifactIds));
    }
}
